<template>
  <div v-if="tips" class="fa-widget-tips__wrapper">
    <div class="fa-widget-tips">{{ tips }}</div>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue'

export default defineComponent({
  name: 'FaWidgetTips',

  props: {
    /** 提示信息 */
    tips: {
      type: String,
      required: true
    }
  }
})
</script>

<style lang="scss">
$max-width: 300px;

.fa-widget-tips {
  display: inline-block;
  box-sizing: border-box;
  margin: auto;
  padding: 4px 6px;
  overflow: hidden;
  color: #fff;
  font-size: 12px;
  line-height: 1.5;
  text-align: left;
  background: rgba($color-text-primary, 0.8);
  border-radius: 4px;
  cursor: default;
  user-select: none;

  &__wrapper {
    position: absolute;
    top: 100%;
    left: 50%;
    width: $max-width;
    height: 0px;
    margin-top: 4px;
    margin-left: math.div(-$max-width, 2);
    text-align: center;
    pointer-events: none;
  }
}
</style>
